Sub Main()
  verbose=false
  sc.print(vbcr & "This script will check what SA/UA there is on a card!" & vbcr & vbcr)
  sc.write("CA A4 04 00 03")
  sc.read(1)
  ppid = sc.inputbox("Input what PPID you want to check SA/UA to","Input PPID","000000")
  sc.print("PPID: " & ppid & vbcr)
  sc.write(ppid)
  sc.read(2)
  if sc.getbyte(1)=8 then
    sc.print("not supported PPID!")
    sc.msgbox("This PPID is not supported by the card!")
    exit sub
  end if
  sc.write("CA AC A5 00 00")
  sc.read(1)
  do while sc.getbyte(0) <> 144 'until 90 is received
    sc.read(1)
  loop
  sc.read(1)
  sc.write("CA B8 00 00 06")
  sc.read(1)
  sc.read(2)
  sc.read(4)
  sa=(hex2(sc.getbyte(0)) & hex2(sc.getbyte(1)) & hex2(sc.getbyte(2)) & hex2(sc.getbyte(3)))
  sc.print( vbcr & "SA IS: " & sa)
  sc.read(2)
  sc.write("CA AC A4 00 00")
  sc.read(1)
  do while sc.getbyte(0) <> 144 'until 90 is received
    sc.read(1)
  loop
  sc.read(1)
  sc.write("CA B8 00 00 07")
  sc.read(1)
  sc.read(2)
  sc.read(5)
  ua=(hex2(sc.getbyte(0)) & hex2(sc.getbyte(1)) & hex2(sc.getbyte(2)) & hex2(sc.getbyte(3)) & hex2(sc.getbyte(4)))
  sc.print( vbcr & "UA IS: " & ua)
  sc.read(2)
End Sub

function hex2(i)
s=hex(i)
  if len(s)=1 then
   s="0" & s
  end if
hex2=s
end function